package com.nahan.secondapplication.VectorIllustration;

import android.graphics.drawable.AnimatedVectorDrawable;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.nahan.secondapplication.R;

/**
  * @描述：svg
  * @date: on 2020/9/10
  */
public class VectorIllustrationActivity extends AppCompatActivity {

    private ImageView img1,img2;

    private Button kaishi,cehui;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vector_illustration);


        img1=findViewById(R.id.img1);
        img2=findViewById(R.id.img2);
        kaishi=findViewById(R.id.kaishi);
        cehui=findViewById(R.id.cehui);

        onClicck();
    }

    /**
     * 监听事件
     */
    private void onClicck() {
        kaishi.setOnClickListener(v ->
                {
                    AnimatedVectorDrawable drawable1 = (AnimatedVectorDrawable)getDrawable(R.drawable.xuehuavector);
                    img1.setImageDrawable(drawable1);
                    drawable1.start();

                    AnimatedVectorDrawable drawable2 = (AnimatedVectorDrawable)getDrawable(R.drawable.jiantouvector);
                    img2.setImageDrawable(drawable2);
                    drawable2.start();
                }
                );

        cehui.setOnClickListener(v ->
                {
                    AnimatedVectorDrawable drawable1 = (AnimatedVectorDrawable)getDrawable(R.drawable.xuehuavector_fan);
                    img1.setImageDrawable(drawable1);
                    drawable1.start();


                    AnimatedVectorDrawable drawable2 = (AnimatedVectorDrawable)getDrawable(R.drawable.jiantouvector_fan);
                    img2.setImageDrawable(drawable2);
                    drawable2.start();
                }
                );
    }
}